<template>
	<view
		style="height: 100%;"
		:style="'background: url('+ c_imgPath + 'chouka/indexBg.png'+ ') repeat-y 0 0 / 100% auto;'">
		<view class="box">
			<view class="title">
				<view class="title_item" 
					v-for="(item,index) in huanxiang_arr" 
					:key="index" 
					@click="huanxiang_click(saixuan_index,item.page_no)">
					<view class="title_text">
						<text :class="page_no==item.page_no?'selectTitle':''">{{item.title}}</text>
					</view>
					<view class="title_img" v-if="page_no==item.page_no">
						<image :src="c_imgPath + 'shouye/xzs_sel.png'"></image>
					</view>
				</view>
			</view>
		</view>
		<!--  -->
		<view class="goods_v">
			<view class="goods_v_item" @click="huanxiang_click(1,page_no)">
				<text :style="'color:'+(saixuan_index==1?'#B07CDD':'')">箱号</text>
				<image :src="c_imgPath+'detail/saixuan' +(saixuan_index==1?'_sel':'')+ '.png'" class="goods_v_1">
				</image>
			</view>
			<view class="goods_v_item" @click="huanxiang_click(2,page_no)">
				<text :style="'color:'+(saixuan_index==2?'#B07CDD':'')">余量</text>
				<image :src="c_imgPath+'detail/saixuan' +(saixuan_index==2?'_sel':'')+ '.png'" class="goods_v_1">
				</image>
			</view>
		</view>
		<view class="shop">
			<view class="shop_item" 
				:style="'background: url('+ c_imgPath + 'detail/xiang_bg.png'+ ') repeat-y 0 0 / 100% 100%;'"
				v-for="(item,index) in huanxiang_Detail" 
				:key="index" 
				@click="getlist(item.num)">
				<view class="shop_item_num"
					:style="'background: url('+ c_imgPath + 'detail/xiang_top.png'+ ') repeat-y 0 0 / 100% 100%;'">
					第{{item.num}}箱
				</view>
				<view class="shop_item_xiang">
					<image v-if="item.surplus_all_stock == 0" :src="c_imgPath+'detail/xiang.png'"></image>
					<image v-else :src="c_imgPath+'detail/xiang_sel.png'"></image>
				</view>
				<view class="shop_item_shang">
					<view class="item" v-for="(v,i) in item.goodslist" :key="i" :class="i%2==0?'left':''">
						<view class="item_left">{{v.shang_title}}</view>
						<view class="item_right">{{v.surplus_stock}}/{{v.stock}}</view>
					</view>
				</view>
				<view class="shop_item_bom"
					:style="'background: url('+ cc_imgPath + 'detail/xiang_bom.png'+ ') repeat-y 0 0 / 100% 100%;'">
					剩余{{item.surplus_all_stock}}个赏品
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				c_imgPath: 'https://qt.yhemall.com/',
				cc_imgPath:'/static/',
				goods_id:'',
				// 换箱头部
				huanxiang_arr: [],
				page_no: 0,
				saixuan_index: 1,
				huanxiang_Detail: [],
			}
		},
		onLoad(o) {
			this.goods_id = o.id;
			this.getgoodslist_count();
			this.huanxiang_click(this.saixuan_index, this.page_no)
		},
		methods: {
			getlist(x){
				uni.setStorageSync('shop_id', this.goods_id);
				uni.setStorageSync('goods_num', x);
				uni.navigateBack({
					delta:1
				})
			},
			// 换箱头部
			getgoodslist_count() {
				let that = this;
				that.req({
					url: 'goodslist_count',
					data: {
						goods_id: that.goods_id
					},
					success(res) {
						if (res.status == 1) {
							that.huanxiang_arr = res.data
						}
					}
				})
			},
			huanxiang_click(a, b) {
				let that = this;
				this.saixuan_index = a
				this.page_no = b
				that.req({
					url: 'goodslist_content',
					data: {
						sort: that.saixuan_index,
						goods_id: that.goods_id,
						page_no: that.page_no,
					},
					success(res) {
						if (res.status == 1) {
							that.huanxiang_Detail = res.data
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
page{
	height: 100%;
}
.box{
	overflow: hidden;
	height: 72rpx;
	.title{
		width: 690rpx;
		margin: auto;
		display: flex;
		overflow-x: scroll;
		padding-bottom: 20rpx;
		.title_item{
			flex-shrink: 0;
			padding: 4rpx 20rpx;
			.title_text{
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #9E99E3;
				display: flex;
				align-items: center;
				justify-content: center;
				.selectTitle{
					font-size: 32rpx;
					background: linear-gradient(0deg, #B75AFF 0%, #E7CBFF 100%);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
				}
				.title_text_rate{
					
				}
			}
			.title_img{
				text-align: center;
				image{
					width: 94rpx;
					height: 24rpx;
				}
			}
		}
	}
}

.goods_v{
	width: 690rpx;
	margin:30rpx auto;
	display: flex;
	align-items: center;
	.goods_v_item{
		margin-right: 30rpx;
		text{
			font-size: 24rpx;
			color: #ffffff;
		}
		image{
			width: 26rpx;
			height: 20rpx;
			margin-left: 10rpx;
		}
	}
}

.shop{
	width: 92%;
	margin: auto;
	display: flex;
	// justify-content: space-around;
	gap: 4%;
	flex-wrap: wrap;
	.shop_item{
		width: 330rpx;
		margin-bottom: 30rpx;
		.shop_item_num{
			width: 100rpx;
			height: 36rpx;
			text-align: center;
			font-size: 24rpx;
			line-height: 36rpx;
			color: #ffffff;
		}
		.shop_item_xiang{
			text-align: center;
			margin-top: 30rpx;
			image{
				width: 110rpx;
				height: 110rpx;
			}
		}
		.shop_item_shang{
			display: flex;
			flex-wrap: wrap;
			// justify-content: space-around;
			padding: 0 20rpx;
			max-height: 160rpx;
			overflow-y: scroll;
			gap: 5%;
			.item{
				width: 45%;
				display: flex;
				margin-bottom: 20rpx;
				.item_left{
					flex: 1;
				}
				.item_left,.item_right{
					font-size: 24rpx;
					color: #ffffff;
				}
			}
			// .left{
			// 	margin-right: 5%;
			// }
		}
		.shop_item_bom{
			text-align: center;
			width: 100%;
			height: 40rpx;
			font-size: 24rpx;
			color: #ffffff;
			line-height: 40rpx;
		}
	}
}
</style>
